From ac166f71971a3cd21003a2395612755c99460115 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 14 Nov 2005 14:28:43 +0000 Subject: [PATCH] Paul Fox and Robert Lipe include tracks and routes in GPX info. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@1584 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/Makefile | 2 +- gpsbabel/defs.h | 3 ++ gpsbabel/gpx.c | 35 ++++++++++---- gpsbabel/reference/coastexp.ref | 2 +- gpsbabel/reference/gdb-sample.gpx | 2 +- gpsbabel/reference/igc1_gpx.out | 1 + gpsbabel/reference/igc2_gpx.out | 1 + gpsbabel/reference/route/compegps-rte.gpx | 1 + gpsbabel/reference/route/cst-sample.gpx | 2 +- gpsbabel/reference/route/mag_pdb-sample.gpx | 2 +- gpsbabel/reference/route/msroute-sample.gpx | 1 + gpsbabel/reference/route/nmn4-sample.gpx | 1 + gpsbabel/reference/route/tef_xml.sample.gpx | 2 +- gpsbabel/reference/track/compegps-trk.gpx | 1 + gpsbabel/reference/track/ignrando-sample.gpx | 1 + gpsbabel/reference/track/pathaway.gpx | 1 + gpsbabel/reference/track/stmwpp-track.gpx | 1 + gpsbabel/reference/track/trackfilter.gpx | 1 + gpsbabel/reference/track/vitosmt_t.gpx | 1 + gpsbabel/waypt.c | 49 ++++++++++++++------ 20 files changed, 82 insertions(+), 28 deletions(-) diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 5632e6dc8..f85e8ef7c 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -1,7 +1,7 @@ VERSU=1_2_8 VERSD=1.2.8 -RELEASE=-beta11082005 +RELEASE=-beta11102005 VERSIONU=$(VERSU)$(RELEASE) VERSIOND=$(VERSD)$(RELEASE) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 97b47b132..fdb1de893 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -355,6 +355,9 @@ waypoint * waypt_new(void); void waypt_del (waypoint *); void waypt_free (waypoint *); void waypt_disp_all(waypt_cb); +void waypt_init_bounds(bounds *bounds); +int waypt_bounds_valid(bounds *bounds); +void waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp); void waypt_compute_bounds(bounds *); void waypt_flush(queue *); void waypt_flush_all(void); diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 8abe43c52..b6cf88acd 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -58,6 +58,8 @@ static char *suppresswhite = NULL; static char *urlbase = NULL; static route_head *trk_head; static route_head *rte_head; +/* used for bounds calculation on output */ +static bounds all_bounds; static format_specific_data **fs_ptr; @@ -196,7 +198,6 @@ static void gpx_rm_from_global(gpx_global_entry *ge) { queue *elem, *tmp; - gpx_global_entry * gep; QUEUE_FOR_EACH(&ge->queue, elem, tmp) { gpx_global_entry *g = (gpx_global_entry *) dequeue(elem); @@ -1562,12 +1563,34 @@ void gpx_route_pr() route_disp_all(gpx_route_hdr, gpx_route_tlr, gpx_route_disp); } +static void +gpx_waypt_bound_calc(const waypoint *waypointp) +{ + waypt_add_to_bounds(&all_bounds, waypointp); +} + +static void +gpx_write_bounds(void) +{ + waypt_init_bounds(&all_bounds); + + waypt_disp_all(gpx_waypt_bound_calc); + route_disp_all(NULL, NULL, gpx_waypt_bound_calc); + track_disp_all(NULL, NULL, gpx_waypt_bound_calc); + + if (waypt_bounds_valid(&all_bounds)) { + fprintf(ofd, "\n", + all_bounds.min_lat, all_bounds.min_lon, + all_bounds.max_lat, all_bounds.max_lon); + } +} + static void gpx_write(void) { time_t now = 0; int short_length; - bounds bounds; gpx_wversion_num = strtod(gpx_wversion, NULL) * 10; @@ -1616,13 +1639,7 @@ gpx_write(void) xml_write_time( ofd, now, "time" ); gpx_write_gdata(&gpx_global->keywords, "keywords"); - waypt_compute_bounds(&bounds); - if (bounds.max_lat > -360) { - fprintf(ofd, "\n", - bounds.min_lat, bounds.min_lon, - bounds.max_lat, bounds.max_lon); - } + gpx_write_bounds(); if (gpx_wversion_num > 10) { fprintf(ofd, "\n"); diff --git a/gpsbabel/reference/coastexp.ref b/gpsbabel/reference/coastexp.ref index 4c5dad94c..492e32f3e 100755 --- a/gpsbabel/reference/coastexp.ref +++ b/gpsbabel/reference/coastexp.ref @@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> - + PESCDR01 diff --git a/gpsbabel/reference/gdb-sample.gpx b/gpsbabel/reference/gdb-sample.gpx index 90a54c69e..727d5faac 100644 --- a/gpsbabel/reference/gdb-sample.gpx +++ b/gpsbabel/reference/gdb-sample.gpx @@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> - + 3 B93 diff --git a/gpsbabel/reference/igc1_gpx.out b/gpsbabel/reference/igc1_gpx.out index 759ad2152..12c7d967d 100644 --- a/gpsbabel/reference/igc1_gpx.out +++ b/gpsbabel/reference/igc1_gpx.out @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + 0001 IGCDATE000000: diff --git a/gpsbabel/reference/igc2_gpx.out b/gpsbabel/reference/igc2_gpx.out index 1a5fb96ed..3b724ea11 100644 --- a/gpsbabel/reference/igc2_gpx.out +++ b/gpsbabel/reference/igc2_gpx.out @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + 0001 IGCDATE160701: 500KTri diff --git a/gpsbabel/reference/route/compegps-rte.gpx b/gpsbabel/reference/route/compegps-rte.gpx index 1ac52bc5e..ed1b3c79c 100644 --- a/gpsbabel/reference/route/compegps-rte.gpx +++ b/gpsbabel/reference/route/compegps-rte.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + test diff --git a/gpsbabel/reference/route/cst-sample.gpx b/gpsbabel/reference/route/cst-sample.gpx index 68a3f4692..82ca4ce63 100644 --- a/gpsbabel/reference/route/cst-sample.gpx +++ b/gpsbabel/reference/route/cst-sample.gpx @@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> - + 1272.900000 diff --git a/gpsbabel/reference/route/mag_pdb-sample.gpx b/gpsbabel/reference/route/mag_pdb-sample.gpx index 109bd3950..8a23e61db 100644 --- a/gpsbabel/reference/route/mag_pdb-sample.gpx +++ b/gpsbabel/reference/route/mag_pdb-sample.gpx @@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> - + Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse diff --git a/gpsbabel/reference/route/msroute-sample.gpx b/gpsbabel/reference/route/msroute-sample.gpx index 677d4d87a..ccffa0d73 100644 --- a/gpsbabel/reference/route/msroute-sample.gpx +++ b/gpsbabel/reference/route/msroute-sample.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + Plauen diff --git a/gpsbabel/reference/route/nmn4-sample.gpx b/gpsbabel/reference/route/nmn4-sample.gpx index 58ae11747..0473d9546 100644 --- a/gpsbabel/reference/route/nmn4-sample.gpx +++ b/gpsbabel/reference/route/nmn4-sample.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + RPT001 diff --git a/gpsbabel/reference/route/tef_xml.sample.gpx b/gpsbabel/reference/route/tef_xml.sample.gpx index 201b69e12..f9e687095 100644 --- a/gpsbabel/reference/route/tef_xml.sample.gpx +++ b/gpsbabel/reference/route/tef_xml.sample.gpx @@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> - + in Zedtwitz halb rechts halten auf B2 Hofer Strasse B2 Hofer Strasse diff --git a/gpsbabel/reference/track/compegps-trk.gpx b/gpsbabel/reference/track/compegps-trk.gpx index a291deefa..06456e1d7 100644 --- a/gpsbabel/reference/track/compegps-trk.gpx +++ b/gpsbabel/reference/track/compegps-trk.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + ACTIVE LOG 006 diff --git a/gpsbabel/reference/track/ignrando-sample.gpx b/gpsbabel/reference/track/ignrando-sample.gpx index 0147b2a03..298cdda3a 100644 --- a/gpsbabel/reference/track/ignrando-sample.gpx +++ b/gpsbabel/reference/track/ignrando-sample.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + 20050719 Mar Tamié ind 2 VTT Sem Europ diff --git a/gpsbabel/reference/track/pathaway.gpx b/gpsbabel/reference/track/pathaway.gpx index 72552ca80..dcad06f9f 100644 --- a/gpsbabel/reference/track/pathaway.gpx +++ b/gpsbabel/reference/track/pathaway.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + 20050116_Fahrradtour Gerd diff --git a/gpsbabel/reference/track/stmwpp-track.gpx b/gpsbabel/reference/track/stmwpp-track.gpx index ba8b2e0b2..f6204f68f 100644 --- a/gpsbabel/reference/track/stmwpp-track.gpx +++ b/gpsbabel/reference/track/stmwpp-track.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + diff --git a/gpsbabel/reference/track/trackfilter.gpx b/gpsbabel/reference/track/trackfilter.gpx index 7bd01cc05..567b34cc6 100644 --- a/gpsbabel/reference/track/trackfilter.gpx +++ b/gpsbabel/reference/track/trackfilter.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + LOG-20020525 diff --git a/gpsbabel/reference/track/vitosmt_t.gpx b/gpsbabel/reference/track/vitosmt_t.gpx index f692d17b2..ff68ffa68 100644 --- a/gpsbabel/reference/track/vitosmt_t.gpx +++ b/gpsbabel/reference/track/vitosmt_t.gpx @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> + diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index bf5a30dc5..bf1af9880 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -208,6 +208,40 @@ waypt_disp_all(waypt_cb cb) } } +void +waypt_init_bounds(bounds *bounds) +{ + /* Set data out of bounds so that even one waypoint will reset */ + bounds->max_lat = -9999; + bounds->max_lon = -9999; + bounds->min_lat = 9999; + bounds->min_lon = 9999; +} + +int +waypt_bounds_valid(bounds *bounds) +{ + /* Returns true if bb has any 'real' data in it */ + return bounds->max_lat > -9999; +} + +/* + * Recompund bounding box based on new position point. + */ +void +waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp) +{ + if (waypointp->latitude > bounds->max_lat) + bounds->max_lat = waypointp->latitude; + if (waypointp->longitude > bounds->max_lon) + bounds->max_lon = waypointp->longitude; + if (waypointp->latitude < bounds->min_lat) + bounds->min_lat = waypointp->latitude; + if (waypointp->longitude < bounds->min_lon) + bounds->min_lon = waypointp->longitude; +} + + /* * Makes another pass over the data to compute bounding * box data and populates bounding box information. @@ -219,22 +253,11 @@ waypt_compute_bounds(bounds *bounds) queue *elem, *tmp; waypoint *waypointp; - /* Set data out of bounds so that even one waypoint will reset */ - bounds->max_lat = -9999; - bounds->max_lon = -9999; - bounds->min_lat = 9999; - bounds->min_lon = 9999; + waypt_init_bounds(bounds); QUEUE_FOR_EACH(&waypt_head, elem, tmp) { waypointp = (waypoint *) elem; - if (waypointp->latitude > bounds->max_lat) - bounds->max_lat = waypointp->latitude; - if (waypointp->longitude > bounds->max_lon) - bounds->max_lon = waypointp->longitude; - if (waypointp->latitude < bounds->min_lat) - bounds->min_lat = waypointp->latitude; - if (waypointp->longitude < bounds->min_lon) - bounds->min_lon = waypointp->longitude; + waypt_add_to_bounds(bounds, waypointp); } } -- 2.30.2